<template>
  <div class="shoppingCar">
    <h1>购物车</h1>
    <div v-for="(item, index) in $store.state.arr" :key="index">

      {{ item.kind }} - {{ item.price }} - {{ item.count }}
      <button @click="$store.commit('add', index)">+</button> 
      <button @click="$store.commit('des', index)">-</button>
    </div>
    <p>总价：￥{{ $store.getters.getSum }}</p>
  </div>
</template>

<script>
export default {
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>
